package com.eduService.teacher.controller;

import com.eduService.teacher.service.IEduSubjectService;
import com.eduService.teacher.utils.R;
import com.eduService.teacher.vo.subject.FirstSubject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Mr.Tang
 * @since 2022-04-29
 */
@RestController
@CrossOrigin
@RequestMapping("/eduSubject")
public class EduSubjectController {

    @Autowired
    IEduSubjectService subjectService;

    /*
    * 读取Excel文件，创建课程数据
    * */
        @PostMapping("readsubject")
        public R readSubject(@RequestBody  MultipartFile file){
            subjectService.readSubject(file,subjectService);
            return R.ok();
        }

        /*
        * 以树状的形式展示课程数据
        * */
    @GetMapping("/getCourse")
    public R showCourse(){
        List<FirstSubject>  Subjects = subjectService.showCourse();
        return R.ok().data("courseList",Subjects);
    }



}
